<template>
    <div style="max-width: 512px; margin: 0 auto;">
        <div class="myBox">
            <div class="L"><img :src="LoginUser.avatar" /></div>
            <div class="C">
                <div class="tit">{{ LoginUser.nickname }}</div>
                <div class="sub">{{ LoginUser.createtime }}</div>
            </div>
            <div class="R"><img src="/public/assets/images/go.png" /></div>
        </div>
        <div class="clear"></div>
        <div class="allkbox"></div>
        <div class="myboxcon" @click="toPage('/business/base/profile')">
            <p>基本资料</p>
            <img src="/public/assets/images/go.png">
        </div>
        <div class="myboxcon" @click="toPage('/business/base/email', 'email')">
            <p>邮箱认证</p>
            <img src="/public/assets/images/go.png">
        </div>
        <div class="myboxcon" @click="toPage('/business/address/index')">
            <p>收货地址</p>
            <img src="/public/assets/images/go.png">
        </div>
        <div class="myboxcon" @click="toPage('/business/order/index')">
            <p>我的订单</p>
            <img src="/public/assets/images/go.png">
        </div>
        <div class="myboxcon" @click="toPage('/business/order/consume')">
            <p>消费记录</p>
            <img src="/public/assets/images/go.png">
        </div>
        <div class="myboxcon" @click="toPage('/business/base/recharge')">
            <p>充值中心</p>
            <img src="/public/assets/images/go.png" >
        </div>
        <div class="myboxcon" @click="toPage('/business/base/rechargelist')">
            <p>充值记录</p>
            <img src="/public/assets/images/go.png">
        </div>
        <div class="myboxcon" @click="logout">
            <p>退出登录</p>
            <img src="/public/assets/images/go.png">
        </div>

        <div class="clear"></div>
        <div class="h54"></div>
        <div class="clear"></div>
        <div class="footerBox">
            <Footer />
        </div>
    </div>
</template>
<script setup>

// 引入路由
const router = useRouter()
// 引入cookies
const { cookies } = useCookies();

// 获取cookies
const LoginUser = reactive(cookies.get('LoginUser') ?? {})// 登录用户信息

// 退出登录
const logout = () => {
    showConfirmDialog({
        title: "退出",
        message: "确认是否退出登录?",
    })
        .then(() => {
            cookies.remove('LoginUser')
            showSuccessToast({
                message: "退出成功",
                onClose: function () {
                    router.push('/business/base/login')
                }
            })
        })
        .catch(() => { })
}

const toPage = (url, msg) => {
    if (msg && LoginUser.auth == '1') {
        showSuccessToast('邮箱已认证,无需认证');
        return false;
    }
    router.push(url)
}
</script>
